<template>
  <div class="app-container">
    <div class="search">
      <!-- 搜索表单 -->
      <el-form :model="serchForm" ref="formRef">
        <el-row :gutter="20">
          <el-col :span="8"
            ><div class="grid-content ep-bg-purple" />
            <el-form-item label="账号名称" prop="account">
              <el-input
                v-model="serchForm.account"
                placeholder="请输入查询的账号名称"
                style="width: 200px"
              ></el-input> </el-form-item
          ></el-col>

          <el-col :span="8"
            ><div class="grid-content ep-bg-purple" />
            <el-form-item label="账号名称2" prop="account">
              <el-input
                v-model="serchForm.account"
                placeholder="请输入查询的账号名称"
                style="width: 200px"
              ></el-input> </el-form-item
          ></el-col>

          <!-- <el-col :span="8"
            ><div class="grid-content ep-bg-purple" />
            <el-form-item label="创建时间" prop="createAt">
              <el-date-picker
                v-model="serchForm.createAt"
                type="daterange"
                range-separator="-"
                start-placeholder="开始时间"
                end-placeholder="结束时间" /></el-form-item
          ></el-col> -->
        </el-row>
      </el-form>
      <!--重置 搜搜按钮 -->
      <div class="btns">
        <el-button icon="Refresh" @click="handleResetClick">重置</el-button>
        <el-button type="primary" icon="Search" @click="handleQueryClick"
          >查询</el-button
        >
      </div>
    </div>

    <!-- 表单 -->
    <div class="content">
      <div class="content">
        <div class="table">
          <el-table :data="usersList" border style="width: 100%">
            <el-table-column align="center" type="selection" width="50px" />
            <el-table-column
              align="center"
              type="index"
              label="序号"
              width="60px"
            />
            <el-table-column
              align="center"
              prop="name"
              label="用户名"
              width="150"
            />

            <el-table-column
              align="center"
              prop="cellphone"
              label="手机"
              width="120"
            />
            <el-table-column
              align="center"
              prop="enable"
              label="状态"
              width="100"
            >
              <!-- 作用域插槽 -->
              <template #default="scope">
                <el-button
                  size="small"
                  plain
                  :type="scope.row.enable ? 'primary' : 'danger'"
                >
                  {{ scope.row.enable ? "启用" : "禁用" }}
                </el-button>
              </template>
            </el-table-column>
            <el-table-column align="center" prop="createAt" label="创建时间">
              <template #default="scope">
                {{ formatUTC(scope.row.createAt) }}
              </template>
            </el-table-column>
            <el-table-column align="center" prop="updateAt" label="更新时间">
              <template #default="scope">
                {{ formatUTC(scope.row.updateAt) }}
              </template>
            </el-table-column>
            <el-table-column align="center" label="操作" width="160">
              <template #default="scope">
                <el-button
                  size="small"
                  type="primary"
                  text
                  icon="Edit"
                  @click="handleEditBtnClick(scope.row)"
                  >编辑</el-button
                >
                <el-button
                  size="small"
                  type="danger"
                  text
                  icon="Delete"
                  @click="handleDeleteBtnClick(scope.row.id)"
                  >删除</el-button
                >
              </template>
            </el-table-column>
          </el-table>
        </div>
        <div class="pagination">
          <el-pagination
            v-model:current-page="currentPage"
            v-model:page-size="pageSize"
            :page-sizes="[10, 20, 30]"
            layout="total,sizes, prev, pager, next, jumper"
            :total="200"
            @size-change="handleSizeChange"
            @current-change="handleCurrentChange"
          />
        </div>
      </div>
    </div>
  </div>
</template>

<script setup>
import { reactive, ref } from "vue";
const serchForm = reactive({
  account: "", //账号
  createAt: "",
});

function handleResetClick() {
  console.log("reset");
}
//查询操作
function handleQueryClick() {
  console.log("handleQueryClick", serchForm);
}

const currentPage = ref(1);
const pageSize = ref(10);
</script>
<style scoped>
label {
  font-weight: 0 !important;
}
.search {
  background-color: #fff;
  padding: 20px;
}
.search .btns {
  text-align: right;
  padding: 0 50px 10px 0;
}
</style>
